<?php

namespace App\Http\Controllers\Web;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;

class FileController extends Controller
{

    public function uploadImg(Request $request)
    {
        $disk = Storage::disk('oss');
        $fileContents = $request->file('file');
        $imgPath = 'images';
        $path = $disk->put(  $imgPath, $fileContents);

        return $this->success($path);
    }

    public function getImg(Request $request)
    {
        $disk = Storage::disk('oss');
        $path = $request->input('path');
        $url = $disk->getUrl($path);

        return  $this->success($url);
    }

    public function getBasePath()
    {
        $disk = Storage::disk('oss');
        return  $this->success($disk->url(''));
    }
}
